using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.IO;
using System.Collections;


namespace RUPS
{
    public partial class VizualizareComenziClientiForm : Form
    {
        DateTime dataIniti, dataFin;
        bool toate;
        public VizualizareComenziClientiForm()
        {
            InitializeComponent();
            CenterToScreen();
        }

        private void VizualizareComenziClientiForm_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'masivDBDataSet13.comenziClienti' table. You can move, or remove it, as needed.
            this.comenziClientiTableAdapter.Fill(this.masivDBDataSet13.comenziClienti);
           

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
                toate = true;
            else
                toate = false;
            if (toate == true)
            {
                this.dataGridView1.DataSource = null;
                SqlDataAdapter da = new SqlDataAdapter("select * from comenziClienti", comenziClientiTableAdapter.Connection);
                DataSet ds = new DataSet();
                da.Fill(ds, "com");
                this.dataGridView1.Rows.Clear();
                this.dataGridView1.DataSource = ds.Tables["com"];
            }
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            dataIniti = dateTimePicker1.Value;
            dataFin = dateTimePicker2.Value;
            if (dataFin != null)
            {
                if (dataFin.CompareTo(dataIniti) < 0)
                {
                    MessageBox.Show("Data finala nu trebuie sa fie anterioare datei initiale. Selectati corect data finala. ");
                }
                else
                {
                    SqlDataAdapter da = new SqlDataAdapter("select * from comenziClienti where dataComanda between '" +
                        dataIniti + "' and '" + dataFin + "'", comenziClientiTableAdapter.Connection);
                    DataSet ds = new DataSet();
                    da.Fill(ds, "com");
                    dataGridView1.DataSource = null;
                    dataGridView1.Rows.Clear();
                    dataGridView1.DataSource = ds.Tables["com"];
                }
            }
            
        }

        private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
        {
            dataFin = dateTimePicker2.Value;
            if (dataFin.CompareTo(dataIniti) < 0)
            {
                MessageBox.Show("Data finala nu trebuie sa fie anterioare datei initiale. Selectati corect data finala. ");
            }
            else
            {
                SqlDataAdapter da = new SqlDataAdapter("select * from comenziClienti where dataComanda between '" +
                    dataIniti + "' and '" +dataFin + "'", comenziClientiTableAdapter.Connection);
                DataSet ds = new DataSet();
                da.Fill(ds, "com");
                dataGridView1.DataSource = null;
                dataGridView1.Rows.Clear();
                dataGridView1.DataSource = ds.Tables["com"];
            }
        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }
    }
}